﻿using System;
using System.Collections.Generic;
using System.Text;
using OpenMas;
using System.Configuration;
using CHelper;

namespace SmsCovert.Service
{
    public class SendMsg
    {
        string PhoneNo = ""; //电话号码
        string Info = "";    //发送信息
        string Url = "";     //服务器地址

        /// <summary>
        /// 构造方法
        /// </summary>
        /// <param name="phone">收接方电话号码</param>
        /// <param name="info">发送的内容</param>
        public SendMsg(string phone, string info)
        {
            this.PhoneNo = phone;
            this.Info = info;
            Url = ConfigurationSettings.AppSettings["Server"].ToString();
        }

        public string Send()
        {
            //这是调用接口发送信息 
            try
            {
                var t = WsCaller.GETWebService(Url, null, "Send");
                object obj = Activator.CreateInstance(t);
                System.Reflection.MethodInfo mi = t.GetMethod("Send");
                object result = mi.Invoke(obj, new object[] { PhoneNo, Info });
                return "true";
            }
            catch (Exception me)
            {
                return "false";
            }
        }
    }
}
